function GetRandomCreateDinoInterval takes nothing returns real
	local real mean = 120.0
	return GetRandomRealTriangleDistribution(mean - 40.0 , mean + 40.0)
endfunction

function SpawnDino takes nothing returns nothing
	local timer spawnTimer = GetExpiredTimer()
	local integer timerId = GetHandleId(spawnTimer)
	local integer createCount = LoadInteger(udg_HT , timerId , StringHash("CREATE_COUNT"))
	//--
	if createCount > 0 then
		call CreateDinoGeneral(GetRandomDinoType() , null) 
		call SaveInteger(udg_HT , timerId , StringHash("CREATE_COUNT") , createCount - 1)
		call TimerStart(spawnTimer , GetRandomReal(0.5 , 1.5) , false , function SpawnDino)
	else
		call PauseTimer(spawnTimer)
		call FlushChildHashtable(udg_HT , timerId)
		call DestroyTimer(spawnTimer)
	endif
	//--
	set spawnTimer = null
endfunction

function CreateDino takes nothing returns nothing
	local timer createDinoTimer = GetExpiredTimer()
	local timer spawnTimer = CreateTimer()
	local integer meanDinoAmount = udg_AmountOfPlayers * 4
	//--
	call SaveInteger(udg_HT , GetHandleId(spawnTimer) , StringHash("CREATE_COUNT") , GetRandomInt(meanDinoAmount / 2 , meanDinoAmount * 3 / 2))
	call TimerStart(spawnTimer , GetRandomReal(0.5 , 1.5) , false , function SpawnDino)
	call TimerStart(createDinoTimer , GetRandomCreateDinoInterval() , false , function CreateDino)
	//--
	set createDinoTimer = null
	set spawnTimer = null
endfunction

function Trig_CreateDino_Actions takes nothing returns nothing
	call TimerStart(CreateTimer() , GetRandomCreateDinoInterval() , false , function CreateDino)
endfunction

function InitTrig_CreateDino takes nothing returns nothing
	local trigger createDinoStartTrigger = CreateTrigger()
	call TriggerRegisterTimerEvent(createDinoStartTrigger , 10.0 , false)
	call TriggerAddAction(createDinoStartTrigger , function Trig_CreateDino_Actions)
endfunction